package laborum2011.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import laborum2011.dao.*;
import laborum2011.excepcion.DAOExcepcion;
import laborum2011.modelo.*;

/**
 * Servlet implementation class PostulanteServlet
 */
@WebServlet("/PostulanteServlet")
public class PostulanteServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public PostulanteServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 int num = Integer.parseInt (request.getParameter("id_pos"));
		 String tipo=request.getParameter("tipo");
		 PersonaDAO pdao= new PersonaDAO();
		 Persona p=new Persona();
		 RequestDispatcher rd;
		 
		 if(num==0){
			 rd = request.getRequestDispatcher("IngresoPersonaP.jsp");
			 rd.forward(request, response);
		 }
		 
		 if(tipo.equals("act")){
				
					try {
						p=pdao.buscarXIdP(num);
						request.setAttribute("p", p);	 
						 rd = request.getRequestDispatcher("ActualizarPersonaP.jsp");
						 rd.forward(request, response);
					} catch (DAOExcepcion e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				
				
		 }
		System.out.println("data "+ num);
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		
		
	
	}

}
